#pragma once
#ifndef QENV__COMMAND__LINE__HH__
#define QENV__COMMAND__LINE__HH__

#include "QEnvPrereqs.h"

class QCmdLine
{
protected:
	static StringVector		mArgs;
	static QCmdLine *		g_Instance;
	QProcConfig				mConfig;

	QCmdLine( int argc = 0, char ** argv = NULL );
	QCmdLine( const QCmdLine& rk ){ throw std::logic_error( "Must access QCmdLine by Instance function e.g it's a singleton" ); }
	virtual ~QCmdLine(void);

	QCmdLine& operator = ( const QCmdLine& rk ){ throw std::logic_error( "Must access QCmdLine by Instance function e.g it's a singleton" );  return *this; }

public:
	
	static QCmdLine& Instance( int argc = 0, char ** argv = NULL ){ 
		static QCmdLine inst(argc, argv);
		if(!g_Instance)
			g_Instance = &inst;
		return *g_Instance;
	}
	static QCmdLine* InstancePtr( int argc = 0, char ** argv = NULL ){ 
		Instance();
		return g_Instance;
	}
	
	void setArguments( unsigned short count, char ** args );
	void setArguments( const StringVector& vec );
	StringVector arguments();

	const bool& isDebug() const{ 
#if !defined(NDEBUG) || defined(_DEBUG)
		static bool dbg = true;
#else
		static bool dbg = true;
#endif
		return dbg;
	}
	bool isQuiet() const{ return mConfig.switches & QPROC_QUIET; }
	bool isCommandLine() const{ return mConfig.switches & QPROC_NOGUI; }
	bool isVerbose() const{ return mConfig.switches & QPROC_NOGUI; }

	QProcConfig& getConfig(){ return mConfig; }
	const QProcConfig& getConfig() const{return mConfig; }

	static StringVector transform( unsigned short count, char ** args )
	{
		StringVector ret;
		for( unsigned short i = count; i < count; i++ )
		{
			ret.push_back( args[i] );
		}
		return ret;
	}
	QProcConfig& process( const StringVector& vec );

	void processFile( const std::string &str );

};

#endif